<template>
  <div class="application-item-box" :style="{ background: bgColor, height: btnHight }">
    <div class="item-box-contant typeCloud">
      <div class="box-left" @click="gotoDetails(itemData.id)">
        <van-image width="44" height="42" radius="6" :src="itemData.icon" />
      </div>

      <div class="box-center" @click="gotoDetails(itemData.id)">
        <div class="box-center-top">
          {{ itemData.name?.length > 16 ? itemData.name?.slice(0, 16) + '...' : itemData.name }}
        </div>
        <div
          class="box-center-bottom"
          :style="{
            color: textColor,
          }"
        >
          {{ itemData.slogan ? sliceStr(itemData.slogan, 22) : itemData.slogan }}
        </div>
      </div>
      <div class="box-right">
        <van-button
          type="primary"
          size="small"
          :color="buttonColo"
          class="down-btn"
          round
          @click="downGame(itemData)"
          >{{ $t('startgame') }}</van-button
        >
        <!-- v-if="btnType == 'gain'" -->
      </div>
    </div>
  </div>
</template>

<script setup>
import { RouterView, useRoute, useRouter } from 'vue-router'

import { computed } from 'vue'
const router = useRouter()
const props = defineProps({
  itemType: {
    type: String,
    default: 'advertising', //advertising  cloud
  },
  buttonColo: {
    type: String,
    default: '', //按钮颜色
  },
  bgColor: {
    type: String,
    default: '', //背景颜色
  },
  btnType: {
    type: String,
    default: 'down', //按钮类型
  },
  btnHight: {
    type: String,
    default: '', //按钮高度
  },
  textColor: {
    type: String,
    default: 'fff', //文本颜色高度
  },
  itemData: {
    type: Object,
    default: {}, //文本颜色高度
  },
})

const gotoDetails = (id) => {
  router.push({
    name: 'gameDetailsMoblie',
    query: {
      id,
    },
  })
}
const downGame = (item) => {
  window.location = item.play_url
}

const sliceStr = computed(() => {
  return function (val, len) {
    return val.length > len ? val.slice(0, len) + '...' : val
  }
})
</script>

<style lang="scss" scoped>
.application-item-box {
  display: flex;
  align-items: center;
  .item-box-contant {
    display: flex;
    align-items: center;
    width: 100%;
  }
  .box-left {
    width: 80px;
    display: flex;
    justify-content: center;
  }

  .typeCloud {
    padding: 10px 0;
  }
  .typeCloud .box-left {
    display: flex;
    justify-content: center;
    justify-content: flex-start;
    width: auto;
    margin-right: 12px;
  }

  .typeCloud .box-right {
    width: auto;
    .down-btn {
      color: #0d7ffe !important;
      font-weight: bold;
    }
  }
  .box-center {
    flex: 1;
    .box-center-top {
      font-weight: bold;
      margin-bottom: 6px;
      font-size: 15px;
    }
    .box-center-bottom {
    }
  }
  .box-right {
    width: 90px;
  }
  .down-btn {
    padding: 8px 20px !important;
    font-size: 14px;
  }
  .white-color {
    color: #fff;
  }
}
</style>
